
//发布视频
function publishVideoFun(){

	var video_url_tmp = $('input[name=url]').val();
	if(video_url_tmp.indexOf('youku')==-1){
		alert('对不起,目前只支持优酷的视频连接!');
		return;
	}
	var video_url = 'http://player.youku.com/embed/';
	if(video_url_tmp.indexOf('v_show/id_')!=-1){
		video_url = video_url + video_url_tmp.substring(video_url_tmp.indexOf('v_show/id_')+10,video_url_tmp.length);
	}else{
		video_url = video_url_tmp;
	}

	$('input[name=url]').val(video_url);
	$.ajax({
        url: API_URL+'curriculum/saveCurriculum?agentid='+agentid+'&type=video',
        type: 'POST',
        dataType: "JSON",
        async: false,
        data:$('#publishVideo').serialize(),
        success: function (obj){
                var detialId = obj.basedata.id;
                if (obj.status.code == 0) {
					window.location='status_detial.html?openid='+openid+'&detialId='+detialId+'&user_status='+user_status;
                    //window.location = 'publish_video.html?openid='+openid+'&detialId='+detialId;
                }else{
                    alert('服务错误');
                }
        },
        error: function (data){
            console.log("服务器异常!");
        }
    });
}



$(function(){
    $('.publish_video').on('click',function(){
        if($('input[name=url]').val().length>0 && $('input[name=title]').val().length>0 && $('input[name=channelid]').val().length>0 && $('input[name=curriculumtypeid]').val().length>0){
            if($('#tabindex').val() == 0 && $('input[name=standardid]').val().length > 0){
                    publishVideoFun();
                }else if($('#tabindex').val() == 1 && $('input[name=standardid]').val()== ''){
                    publishVideoFun();
            }

        }else{
            alert('请完善选项')
        }
    })
})